<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>模拟新浪切片照片</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        #total{
            width: 340px;
            height: 300px;
            /*background-color: #99ff99;*/
            margin:20px auto;
        }
        #div01{
            width: 170px;
            height: 300px;
            background-image: url("../imagconman/left.png");
            display: inline-block;
        }
        #div02{
            width: 170px;
            height: 300px;
            background-image: url("../imagconman/right.png");
            float: right;
        }
    </style>
    <script>
        window.onload=function () {
            var div01=document.getElementById("div01");
            var div02=document.getElementById("div02");
            var total=document.getElementById("total");
                total.style.backgroundImage=" url(../imagconman/2020318.png)";
                total.style.backgroundRepeat="no-repeat";
            var imgArr=["../imagconman/2020318.png","../imagconman/荷花.png","../imagconman/向日葵.png","../imagconman/蝗虫.png"];
            var index=0;
                div01.onclick=function () {
                //上一页
                    index--;
                    if (index<0){
                        index=imgArr.length-1;
                    }
                    total.style.backgroundImage="url("+imgArr[index]+")";
                };
            div02.onclick=function () {
                //下一页
                index++;
                if (index>3){
                    index=0;
                }
                total.style.backgroundImage="url("+imgArr[index]+")"

            };
        }
    </script>
</head>
<body>
<div id="total">
    <div id="div01"></div>
    <div id="div02"></div>
</div>
</body>
</html>